<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script>
//        1、三个数比大小
        var a=1;
        var b=2;
        var c=3;
        var d;
        if(a>b){
            if(b>c){
                console.log(a,b,c);
            }else{
                console.log(a,c,b);
            }
        }
        if(b>c){
            if(a>c){
                console.log(b,a,c);
            }else{
                console.log(b,c,a);
            }
        }
        if(c>a){
            if(a>b){
                console.log(c,a,b);
            }else{
                console.log(c,b,a);
            }
        }
//2、声明一个带参函数，计算出n的立方  n*n*n
        function arr(n) {
            return n*n*n;
        }
        console.log("立方为"+arr(100));
//数组中找到最大值并返回最大值
        var arr1=[1,2,3,4,5,6,7];
        var max=0;
        for(i=0;i<arr1.length;i++){
            if(max<arr1[i]){
                max=arr1[i];
            }
        }
        console.log(max);
//4、定义方法三个数的和
        function  sum(num1,num2,num3) {
            return num1+num2+num3;
        }
        console.log(sum(10,20,30));
//5、预习三元运算符
        var one=10;
        var two=20;
        var three=30;
        one<two?one=two:" ";
        one<three?one=three:" ";
        console.log(one);

//6、复习用户登录功能
        function dl() {
            name=document.getElementById("name").value;
            pwd=document.getElementById("pwd").value;
            if(name=="张三"&&pwd==123456){
                alert("登陆成功");
            }else {
                alert("用户名或密码输入错误");
            }
        }
//7、冒泡排序
        var arr2=[1,3,5,7,9,0,2,4,6,8]
        var x;
        for(i=0;i<arr2.length;i++){
            for(j=0;j<arr2.length-i;j++){
                if(arr2[j]>arr2[j+1]){
                    x=arr2[j];
                    arr2[j]=arr2[j+1];
                    arr2[j+1]=x;
                }
            }
        }
        console.log(arr2);
//8、九九乘法表
        var sum;
        for(i=1;i<=9;i++){
            for(j=1;j<=i;j++){
                document.write(j+"*"+i+"="+j*i);
                document.write('&nbsp;');
            }
            document.write('<br>');
        }
//9、计算1-100之间的能被7整除的数
        var ct=0;
        for(i=1;i<=100;i++){
            if(i%7==0){
                console.log(i);
                ct++;
            }
        }
        console.log(" ");
        console.log(ct);
//10、电子表，使用定时任务
        onload=function () {
            time();
            function time() {
                var day=new Date();
                 y=day.getFullYear();
                 mo=day.getMonth()+1;
                 d=day.getDate();
                 h=day.getHours();
                 m=day.getMinutes();
                 se=day.getSeconds();
                 str=y+"年"+mo+"月"+d+"日"+h+":"+m+":"+se;
                 document.getElementById("text").innerHTML=str;
                 setInterval(time,1000);
            }
        }
//11、计算器

        function jg(a) {
            one=document.getElementById("one").value;
            two=document.getElementById("two").value;
            var sum=0;
            if(a=="+"){
                sum=Number(one)+Number(two);
            }
            if(a=="-"){
                sum=Number(one)-Number(two);
            }
            if(a=="*"){
                sum=Number(one)*Number(two);
            }
            if(a=="/"){
                sum=Number(one)/Number(two);
            }
            document.getElementById("three").value=sum;
        }



    </script>
</head>
<body>
<input type="text" placeholder="请输入用户名" id="name">
<input type="password" placeholder="请输入密码" id="pwd">
<input type="button" id="dj" value="登录" onclick="dl(value)">
<p id="text"></p>

<input type="text" id="one">
<input type="text" id="two">
<input type="button" value="+" onclick="jg(value)" >
<input type="button" value="-" onclick="jg(value)" >
<input type="button" value="*" onclick="jg(value)" >
<input type="button" value="/" onclick="jg(value)" >
<input type="text" id="three">
</body>
</html>